﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace gChartSharp
{
    /// <summary>
    /// http://code.google.com/apis/chart/#data_scaling
    /// </summary>
    public class ChartDataScale : IChartParam
    {

        /// <summary>
        /// The name of the API
        /// </summary>
        public string Name { get { return "chds"; } }


        /// <summary>
        /// The lower limit of data values to dsplay
        /// </summary>
        public float Minimum { get; set; }


        /// <summary>
        /// The upper limit of data values to display
        /// </summary>
        public float Maximum { get; set; }


        /// <summary>
        /// Constructor to initialize all properties
        /// </summary>
        /// <param name="minimum"></param>
        /// <param name="maximum"></param>
        public ChartDataScale(float minimum, float maximum)
        {
            this.Minimum = minimum;
            this.Maximum = maximum;
        }


        public ChartDataScale(int minimum, int maximum)
        {
            this.Minimum = (float)minimum;
            this.Maximum = (float)maximum;
        }


        /// <summary>
        /// Hide default constructor
        /// </summary>
        private ChartDataScale() { }


        /// <summary>
        /// Render the API text
        /// </summary>
        /// <returns></returns>
        public string Render()
        {
            StringBuilder sb = new StringBuilder();
            sb.Append(String.Format("&{0}={1},{2}", this.Name, this.Minimum.ToString(), this.Maximum.ToString()));
            return sb.ToString();
        }
    }
}
